
package com.stnet.web.left;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.modules.commons.PageAction;
import com.stnet.entity.EnterpriseColumn;

public class CollectionAction extends PageAction
{
	private String dtree;
	
	private Long father;
	
	private List<EnterpriseColumn> columnList = new ArrayList<EnterpriseColumn>();
	
    public Long getFather() {
		return father;
	}


	public void setFather(Long father) {
		this.father = father;
	}



	public String execute()throws Exception
    {
		Authorize isAuthorize = new Authorize();
		
		dtree = "";
		columnList = this.epColumnManagerDao.findAllEnterpriseColumn();
		//初始化tree
		Map map = null;
		map = new HashMap();
		for(EnterpriseColumn ec : columnList){
			
			if(isAuthorize.isAuthorize(ec.getNames()) || (map.get(ec.getFather().toString())!=null)){
				if(ec.getFather()==0){
					map.put(String.valueOf(ec.getId()),"true");
				}
			/**
			 * 如果为链接,则不显示*/
			if("link".equals(ec.getTypeColumn()))continue;
			/**
			 * 如果为内容模块,则直接进行编辑
			 * */
			if("content".equals(ec.getTypeColumn()))
				dtree += "d.add("+ec.getId()+","+ec.getFather()+",'"+
					ec.getNames()+" [<font color=red>单页</font>]','collection/epNewsAction!query.action?father="+ec.getId()+"','"+ec.getNames()+"','mainFrame');";
			/**
			 * 如果为列表模块,则进入新闻列表页面
			 * */
			if("list".equals(ec.getTypeColumn()) || "mostlist".equals(ec.getTypeColumn()))
				dtree += "d.add("+ec.getId()+","+ec.getFather()+",'"+
					ec.getNames()+" [<font color=red>新闻</font>]','collection/epNewsAction!query.action?father="+ec.getId()+"','"+ec.getNames()+"','mainFrame');";
			/**
			 * 如果为下载模块,则进入下载列表页面
			 * */
			if("download".equals(ec.getTypeColumn()))
				dtree += "d.add("+ec.getId()+","+ec.getFather()+",'"+
					ec.getNames()+" [<font color=red>下载</font>]','collection/epNewsAction!query.action?father="+ec.getId()+"','"+ec.getNames()+"','mainFrame');";
			}
		}
        return "success";
    }

    
    public String findTree()throws Exception
    {
    	//this.setColumnlist(this.epColumnManagerDao.findTreeByFather(father));
    	
    	return "success";
    }
    
    private List epColumnOutList;


	public List getEpColumnOutList() {
		return epColumnOutList;
	}

	public void setEpColumnOutList(List epColumnOutList) {
		this.epColumnOutList = epColumnOutList;
	}


	public String getDtree() {
		return dtree;
	}


	public void setDtree(String dtree) {
		this.dtree = dtree;
	}

}